/*
 *  atBudget Personal Finance Management application
 *
 *  Copyright 2011, Ilia Frenkel <frenkel.ilia@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
	Currencies list. This list is used in the currencies management dialogue.
 */
Ext.define('ATB.view.currency.List' ,{
	extend: 'Ext.grid.Panel',
	alias : 'widget.currencylist',
	store : 'Currencies',
	title : 'Currencies',
	hideHeaders: true,
	viewConfig: {
		emptyText: '<p style="text-align:center;color:#999999;font-weight: '+
			'bold;font-size:120%;margin-top:2em">No currencies found.</p>',
		singleSelect: true,
		allowDeselect: false,
		stripeRows: true
	},
	bodyCls: 'atb-currencylist',

	initComponent: function() {
		this.columns = [
			{header: 'Code', dataIndex: 'code', flex: 1, renderer: renderCurrencyRow}
/*
			{header: 'Name',      dataIndex: 'name',          flex: 1},
			{header: 'Code',      dataIndex: 'code',          flex: 1},
			{header: 'Prefix',    dataIndex: 'prefix',        flex: 1},
			{header: 'Suffix',    dataIndex: 'suffix',        flex: 1},
			{header: 'Thousands', dataIndex: 'thousands',     flex: 1},
			{header: 'Decimal',   dataIndex: 'decimal',       flex: 1},
			{header: 'Precision', dataIndex: 'precision',     flex: 1}
*/
		];
		
		this.callParent(arguments);
	}
});

/*
	Custom renderer for a row in the list.
*/
function renderCurrencyRow(value, p, record) {
	return Ext.String.format('<div style="cursor:pointer">'+
		'<div style="font-weight:bold;font-size:130%">{0}'+
		'<div style="color:#777777;float:right;font-weight:normal;'+
		'font-size:80%">Example:&nbsp;{2}</div>'+
		'</div>'+
		'<div style="color:#777777;font-style:italic;font-family:Georgia,Serif;'+
		'white-space:normal;">{1}</div>'+
		'</div>',
		value, record.data.name, record.data.examplefmt);
}
